package com.qingcloud.adminbackend.enums;

/**
 * 数据源类型
 *
 * @author yangfan
 * @since 2021/12/6 11:21
 */
public enum DataSourceEnum {

    /**
     * mysql
     */
    MYSQL(1, "MySQL", "&#xe6c8;"),

    /**
     * pgsql
     */
    PGSQL(2, "PostgreSQL", "&#xe8b7;"),
    /**
     * oracle
     */
    ORACLE(3, "Oracle", "&#xe624;"),
    /**
     * sqlserver
     */
    SQLSERVER(4, "Microsoft SQL Server", "&#xe65b;"),
    MONGO(5, "MongoDB", "&#xe745;"),
    REDIS(6, "Redis", "&#xe668;"),
    ;

    /**
     * 类型
     */
    public final Integer code;

    /**
     * 名称
     */
    public final String desc;

    /**
     * 图标
     */
    public final String icon;

    DataSourceEnum(Integer code, String desc, String icon) {
        this.code = code;
        this.desc = desc;
        this.icon = icon;
    }

    public static DataSourceEnum getByCode(Integer code) {
        for (DataSourceEnum dataSourceEnum : DataSourceEnum.values()) {
            if (dataSourceEnum.code.equals(code)) {
                return dataSourceEnum;
            }
        }
        return MYSQL;
    }
}
